// (C) Andrea Giammarchi
bytefx=new function(){this.alpha=function(element,opacity){var style=$element(element).style;style.opacity=style.MozOpacity=style.KhtmlOpacity=opacity/100;style.filter="alpha(opacity="+opacity+")";};this.clear=function(element){var interval=["size","scroll","move","fade","color"],index=interval.length;while(index--)clearInterval($element(element).bytefx[interval[index]]);};this.color=function(element,style,start,end,speed,callback){end=bytefx.color$(end);clearInterval($element(element).bytefx.color);element.bytefx.color=setInterval(function(){var color=bytefx.color$(start),index=3;while(index--)color[index]=$end(color[index],end[index],speed);element.style[style]=start=bytefx.$color(color);if(""+color==""+end)$callback(element,"color",callback);},1);};this.drag=function(element,start,end,callback,position){function $callback(evt,callback){if(callback)callback.call(element,evt);return false;};var tmp=$element(element).bytefx.drag;bytefx.$event(element,"onmousedown",function(evt){tmp.start=true;tmp.onmousedown=d.onmousedown;tmp.onmouseup=d.onmouseup;d.onmouseup=element.onmouseup;d.onmousedown=$callback;return $callback(evt,start);});bytefx.$event(element,"onmouseup",function(evt){tmp.start=false;d.onmousedown=tmp.onmousedown;d.onmouseup=tmp.onmouseup;return $callback(evt,end);});bytefx.$event(d,"onmousemove",function(evt){var x=evt.clientX,y=evt.clientY,size={x:x-tmp.x,y:y-tmp.y};if(tmp.start){if(position){size.x=max(size.x,position.$x);size.y=max(size.y,position.$y);size.x=min(size.x,position.x$);size.y=min(size.y,position.y$);};bytefx.position(element,size);$callback(evt,callback);}else{tmp.x=x-element.offsetLeft;tmp.y=y-element.offsetTop;};return false;});};this.fade=function(element,start,end,speed,callback){clearInterval($element(element).bytefx.fade);element.bytefx.fade=setInterval(function(){start=$end(start,end,speed);bytefx.alpha(element,start);if(start==end)$callback(element,"fade",callback);},1);};this.move=function(element,position,speed,callback){var start=bytefx.$position($element(element));$setInterval(element,"move",speed/100,start,position,["x","y"],"position",callback);};this.position=function(element,position){var style=$element(element).style;style.position="absolute";style.left=position.x+"px";style.top=position.y+"px";};this.scroll=function(element,speed,callback){function scroll(position){return d.documentElement?d.documentElement[position]:d.body[position];};var start=bytefx.$scroll(),end={x:start.x,y:min(bytefx.$position(element).y,max(scroll("offsetHeight"),d.body.offsetHeight)-min(scroll("clientHeight"),d.body.clientHeight))};$setInterval($element(bytefx),"scroll",speed/100,start,end,["x","y"],"scroll$",callback?function(){callback.call(element)}:null);};this.size=function(element,size,speed,callback){var start=bytefx.$size($element(element)),tmp=w.opera;if(!/msie/i.test(navigator.userAgent)||(tmp&&parseInt(tmp.version())>=9)){if(size.$width)start.width-=size.$width;if(size.$height)start.height-=size.$height;if(size.width$)size.width-=size.width$;if(size.height$)size.height-=size.height$;};element.style.overflow="hidden";$setInterval(element,"size",speed/100,start,size,["width","height"],"size$",callback);};this.$color=function(color){function tmp(index){var tmp=color[index].toString(16);return tmp.length==1?"0"+tmp:tmp;};return"#"+tmp(0)+tmp(1)+tmp(2);};this.color$=function(color){function tmp(index){return color.charAt(index);};color=color.substring(1);if(color.length==3)color=tmp(0)+tmp(0)+tmp(1)+tmp(1)+tmp(2)+tmp(2);return[parseInt(tmp(0)+tmp(1),16),parseInt(tmp(2)+tmp(3),16),parseInt(tmp(4)+tmp(5),16)];};this.$event=function(element,tmp,callback){var value=element[tmp];element[tmp]=function(evt){if(!evt)evt=w.event;if(value)value.call(this,evt);return callback.call(this,evt);};};this.$position=function(element){var position={x:element.offsetLeft,y:element.offsetTop};while(element=element.offsetParent){position.x+=element.offsetLeft;position.y+=element.offsetTop;};return position;};this.$scroll=function(){function scroll(position,scroll){return(d.documentElement?d.documentElement[position]:w[scroll]||d.body[position])||0;};return{x:scroll("scrollLeft","pageXOffset"),y:scroll("scrollTop","pageYOffset")};};this.scroll$=function(element,position){w.scrollTo(position.x,position.y);};this.$size=function(element){return{width:element.offsetWidth,height:element.offsetHeight};};this.size$=function(element,size){var style=element.style;style.width=size.width+"px";style.height=size.height+"px";};function $callback(element,interval,callback){clearInterval(element.bytefx[interval]);if(callback)callback.call(element);};function $element(element){if(!element.bytefx)element.bytefx={color:0,drag:{},fade:0,move:0,scroll:0,size:0};return element;};function $end(x,y,speed){return x<y?min(x+speed,y):max(x-speed,y);};function $setInterval(element,interval,speed,start,position,style,tmp,callback){clearInterval(element.bytefx[interval]);element.bytefx[interval]=setInterval(function(){start[style[0]]+=(position[style[0]]-start[style[0]])*speed;start[style[1]]+=(position[style[1]]-start[style[1]])*speed;bytefx[tmp](element,start);if(round(start[style[0]])==position[style[0]]&&round(start[style[1]])==position[style[1]]){bytefx[tmp](element,position);$callback(element,interval,callback);}},1);};var w=window,d=document,max=Math.max,min=Math.min,round=Math.round;};
bytedom=new function(){this.addClassName=function(element,className){var search=(element=get(element)).className;if(!search||!new RegExp("\\b".concat(search,"\\b"),"i").test(className))element.className+=!!search?" ".concat(className):className;return element;};this.addEvent=function(element,evt,callback){element=get(element);if(evt==="DOMContentLoaded")onContent(callback);else if(element[e]&&(!o||!event[evt]))element[e](evt,callback,false);else if(/MSIE/i.test(b))element.attachEvent(eventName(evt),callback);return element;};this.clear=function(element){return bytedom.forEach(function(e){bytedom.remove(e)},bytedom.filter(function(e){return e.nodeType===3},(element=get(element)).childNodes));};this.create=function(){return create(arguments,"createElement");};this.every=function(callback,element){for(var result=true,i=0;i<element.length&&result;i++)result=callback(element[i],i,element);return result;};this.filter=function(callback,element){for(var result=[],i=0;i<element.length;i++){if(callback(element[i],i,element))result[result.length]=element[i];};return result;};this.forEach=function(callback,element){for(var i=0;i<element.length;i++)callback(element[i],i,element);return element;};this.get=get;this.getStyle=function(element,search){var result="";element=get(element);if(d[v]&&d[v].getComputedStyle)result=d[v].getComputedStyle(element,"").getPropertyValue(search);else if(element.currentStyle)result=element.currentStyle[search.replace(/\-(\w)/g,function(search,result){return result.toUpperCase()})];return result;};this.pop=function(parent){var element=null,length=(parent=get(parent)).childNodes.length;if(length--)parent.removeChild(element=parent.childNodes[length]);return element;};this.preventDefault=function(evt){evt.returnValue=false;if(evt.preventDefault)evt.preventDefault();return evt;};this.push=function(parent){parent=get(parent);for(var i=1;i<arguments.length;i++)parent.appendChild(get(arguments[i]));return parent;};this.remove=function(element){element=get(element);element.parentNode.removeChild(element);return element;};this.removeClassName=function(element,className){var search=new RegExp("\\b".concat(className,"\\b"),"i");if(search.test((element=get(element)).className))element.className=element.className. replace(search," "). replace(/\s+/g," "). replace(/^\s+|\s+$/,"");return element;};this.removeEvent=function(element,evt,callback){element=get(element);if(evt==="DOMContentLoaded")w[c]=function(){};if(element[r]&&(!o||!event[evt]))element[r](evt,callback,false);else if(/MSIE/i.test(b))element.detachEvent(eventName(evt),callback);return element;};this.replace=function(parent,element){parent=get(parent);parent.parentNode.replaceChild(element=get(element),parent);return element;};this.reverse=function(parent){var i=0,element=childNodes(parent=get(parent));element.reverse();while(i<element.length)bytedom.push(parent,element[i++]);return parent;};this.shift=function(parent){var element=null;if((parent=get(parent)).childNodes.length)parent.removeChild(element=parent.childNodes[0]);return element;};this.some=function(callback,element){for(var result=false,i=0;i<element.length&&!result;i++)result=callback(element[i],i,element);return result;};this.text=function(){return create(arguments,"createTextNode");};this.toggle=function(element){var search=-1;element=get(element);if(!bytedom.some(function(e){return e.element===element},collection))collection[collection.length]={element:element,display:element.style.display,visibility:element.style.visibility};if(element.style.display!=="none"){element.style.display="none";element.style.visibility="hidden";}else{bytedom.forEach(function(e,i){if(e.element===element){element.style.display=e.display;element.style.visibility=e.visibility;search=i;}},collection);if(search>-1)collection.splice(search,1);};return element;};this.unshift=function(parent){var i=1,element=(parent=get(parent)).childNodes.length;if(!element)bytedom.push(parent,bytedom.create("div"));while(i<arguments.length)parent.insertBefore(get(arguments[i++]),parent.childNodes[0]);if(!element)bytedom.pop(parent);return parent.childNodes.length;};function childNodes(parent){var t,element=[];while(t=bytedom.shift(parent))element[element.length]=t;return element;};function create(parent,event){for(var i=0,element=[];i<parent.length;i++)element[i]=d[event](parent[i]);return i===1?element[0]:element;};function eventName(evt){return event[evt]||"on".concat(evt);};function get(){var i=0,element=[];switch(arguments.length){case 1:if(arguments[0].constructor===String){if(/^(\w+|\*)\.\w+/.test(arguments[0])){for(var t=arguments[0].split("."),r=new RegExp("\\b".concat(t[1],"\\b"),"i"),e=t[0]==="*"&&d.all?d.all:d.getElementsByTagName(t[0]);i<e.length;i++){if(t[1]==="*"||r.test(e[i].className))element[element.length]=e[i];}}else if(!(element=d.getElementById(arguments[0]))){element=[];for(var e=d.getElementsByTagName(arguments[0]);i<e.length;i++)element[i]=e[i];}}else element=arguments[0];break;default:for(;i<arguments.length;i++)element[i]=get(arguments[i]);break;};return element;};function onContent(f){var a,r="readyState",s="<scr".concat("ipt defer src='//:' on",r,"change='if(this.",r,"==\"complete\"){bytedom.remove(this);",c,"()}'></scr","ipt>");w[c]=(function(o){return function(){w[c]=function(){};for(a=arguments.callee;!a.done;a.done=1)f(o?o():o)}})(w[c]);if(d[e])d[e]("DOMContentLoaded",w[c],false);if(/WebKit|Khtml/i.test(b)||(o&&parseInt(o.version())<9))(function(){/loaded|complete/.test(d[r])?w[c]():setTimeout(arguments.callee,1)})();else if(/MSIE/i.test(b))d.write(s);};var b=navigator.userAgent,d=document,w=window,c="__onContent__",e="addEventListener",r="removeEventListener",v="defaultView",o=window.opera,collection=[],event={DOMActivate:"ondomactivate",DOMAttrModified:"onattrmodified",DOMCharacterDataModified:"oncharacterdatamodified",DOMFocusIn:"ondomfocusin",DOMFocusOut:"ondomfocusout",DOMMouseScroll:"onmousewheel",DOMNodeInserted:"onnodeinserted",DOMSubtreeModified:"onsubtreemodified",NodeInsertedIntoDocument:"onnodeinsertedintodocument"};};
byteson=new function(){this.convert=function(params,result){switch(params.constructor){case Boolean||(Number&&isFinite(params)):result=String(params);break;case Date:result='"'.concat(params.getFullYear(),'-',common.d(params.getMonth()+1),'-',common.d(params.getDate()),'T',common.d(params.getHours()),':',common.d(params.getMinutes()),':',common.d(params.getSeconds()),'"');break;case String:if(/^[0-9]{4}\-[0-9]{2}\-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}$/.test(params)){result=new Date;result.setHours(common.i(params,11,2));result.setMinutes(common.i(params,14,2));result.setSeconds(common.i(params,17,2));result.setMonth(common.i(params,5,2)-1);result.setDate(common.i(params,9,2));result.setFullYear(common.i(params,0,4));};break;default:var n,tmp=[];if(result){for(n in params)result[n]=params[n];}else{for(n in params){if(params.hasOwnProperty(n)&&!!(result=byteson.encode(params[n])))tmp.push(byteson.encode(n).concat(':',result));};result='{'.concat(tmp.join(','),'}');};break;};return result;};this.decode=function(params){var tmp=new RegExp('^("(\\\\.|[^"\\\\\\n\\r])*?"|[,:{}\\[\\]0-9.\\-+Eaeflnr-u \\n\\r\\t])+?$');return tmp.test(params)?eval('('.concat(params,')')):undefined;};this.encode=function(params){var result='';if(params===null)result='null';else if(!{'function':1,'undefined':1,'unknown':1}[typeof(params)]){switch(params.constructor){case Array:for(var i=0,j=params.length,tmp=[];i<j;i++){if(!!(result=byteson.encode(params[i])))tmp.push(result);};result='['.concat(tmp.join(','),']');break;case String:var n={'\b':'b','\t':'t','\n':'n','\f':'f','\r':'r','"':'"','\\':'\\','/':'/'};result='"'.concat(params.replace(/(\x5c|\x2F|\x22|[\x0c-\x0d]|[\x08-\x0a])/g,common.s).replace(/([\x00-\x07]|\x0b|[\x0e-\x1f])/g,common.u),'"');break;default:result=byteson.convert(params);break;};};return result;};this.request=function(page,params,options){return(function(page,params,options){function error(status){if(options.error)options.error(status,xhr,request);};var timeout=0,tmp=[],xhr=byteson.xhr(),request={page:page,params:params,options:options};if(xhr){tmp=[function(n){if(n)tmp[n]=tmp[1]},function(){},function(){if(options.send)options.send(xhr,request);tmp[0](2)},function(){if(options.loading)options.loading(xhr,request);tmp[0](3)},function(){if(options.timeout)clearTimeout(timeout);if({200:1,304:1}[xhr.status]){if(options.load)options.load(byteson.decode(tmp[5](xhr.responseText)),xhr,request);}else error('Request failure\nStatus '.concat(xhr.status));},function(s){return options.decode?decodeURIComponent(s):s},options.async!==undefined?options.async:true,options.user?options.user:'',options.pass?options.pass:''];if(params===null)xhr.open('get',page,tmp[6],tmp[7],tmp[8]);else{xhr.open('post',page,tmp[6],tmp[7],tmp[8]);xhr.setRequestHeader('Content-Length',params.length);xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');};xhr.onreadystatechange=function(){tmp[xhr.readyState]()};if(options.init)options.init(xhr);if(options.timeout)timeout=setTimeout(function(){xhr.abort();error('timeout')},options.timeout);xhr.send(params);};return xhr?true:false;})(page,params===null||params===undefined?null:'byteson='.concat(encodeURIComponent(byteson.encode(params))),options||{});};this.xhr=function(){var xhr=null,n=7;if(window.XMLHttpRequest)xhr=new XMLHttpRequest;else if(window.ActiveXObject){while(!xhr){try{xhr=new ActiveXObject(['Msxml2','XMLHTTP',n,'0'].join('.'))}catch(e){--n}}};return xhr;};var common={c:{'\b':'b','\t':'t','\n':'n','\f':'f','\r':'r','"':'"','\\':'\\','/':'/'},d:function(n){return n<10?'0'.concat(n):n},i:function(e,p,l){return parseInt(e.substr(p,l))},s:function(i,d){return'\\'.concat(common.c[d])},u:function(i,d){var n=d.charCodeAt(0).toString(16);return'\\u'.concat(n.length<2?'000':'00',n)}};};overbyte={
JSFolder:"javascript/",
JSExtension:"js",
JSRules:[
{name:"doublequote", start:"\"", end:"\"", noslash:true},
{name:"singlequote", start:"'", end:"'", noslash:true},
{name:"singlelinecomment", start:"//", end:["\n","\r"]},
{name:"multilinecomment", start:"/*", end:"*/"},
{name:"regexp", start:"/", end:"/", match:/^\/[^\n\r]+\/$/, noslash:true}
],
getContent:function(filename){
var	xhr=byteson.xhr();
xhr.open("get", filename, false);
xhr.send(null);
return xhr.responseText
},
include:function(){
bytedom.forEach(function(plugin){
if(!overbyte[plugin])
eval(overbyte.getContent(overbyte.JSFolder.concat("overbyte/", plugin,".", overbyte.JSExtension)));
}, arguments)
}
};overbyte.SourceMap = function(source, delimeters) {
function getMap() {
var sourcePosition = 0,
delimetersPosition = 0,
findLength = 0,
len = 0,
tempIndex = 0,
sourceLength = source.length,
delimetersLength = delimeters.length,
tempPosition = -1,
endPosition = -1,
map = [],
tempMap = [],
tempDelimeter = {};
while(sourcePosition < sourceLength) {
endPosition = -1;
for(delimetersPosition = 0; delimetersPosition < delimetersLength; delimetersPosition++) {
tempPosition = source.indexOf(delimeters[delimetersPosition].start, sourcePosition);
if(tempPosition !== -1 && (tempPosition < endPosition || endPosition === -1)) {
endPosition = tempPosition;
tempIndex = delimetersPosition;
}
}
if(endPosition !== -1) {
sourcePosition = endPosition;
tempDelimeter = delimeters[tempIndex];
findLength = tempDelimeter.start.length;
if(tempDelimeter.end.constructor === Array) {
delimetersPosition = 0;
endPosition = -1;
for(len = tempDelimeter.end.length; delimetersPosition < len; delimetersPosition++) {
tempPosition = source.indexOf(tempDelimeter.end[delimetersPosition], sourcePosition + findLength);
if(tempPosition !== -1 && (tempPosition < endPosition || endPosition === -1)) {
endPosition = tempPosition;
tempIndex = delimetersPosition;
}	}
if(endPosition !== -1)
endPosition = endPosition + tempDelimeter.end[tempIndex].length;
else
endPosition = sourceLength;
map.push({name:tempDelimeter.name, start:sourcePosition, end:endPosition});
sourcePosition = endPosition - 1;
}
else if(tempDelimeter.match) {
tempPosition = source.indexOf(tempDelimeter.end, sourcePosition + findLength);
len = tempDelimeter.end.length;
if(tempPosition !== -1 && tempDelimeter.match.test(source.substr(sourcePosition, tempPosition - sourcePosition + len))) {
endPosition = tempDelimeter.noslash ? __endCharNoSlash(source, sourcePosition, tempDelimeter.end, sourceLength) : tempPosition + len;
map.push({name:tempDelimeter.name, start:sourcePosition, end:endPosition});
sourcePosition = endPosition - 1;
}
}
else {
if(tempDelimeter.noslash)
endPosition = __endCharNoSlash(source, sourcePosition, tempDelimeter.end, sourceLength);
else {
tempPosition = source.indexOf(tempDelimeter.end, sourcePosition + findLength);
if(tempPosition !== -1)
endPosition = tempPosition + tempDelimeter.end.length;
else
endPosition = sourceLength;
};
map.push({name:tempDelimeter.name, start:sourcePosition, end:endPosition});
sourcePosition = endPosition - 1;
}
}
else
sourcePosition = sourceLength - 1;
++sourcePosition;
};
len = map.length;
if(len === 0)
tempMap.push({name:'code', start:0, end:sourceLength});
else {
for(tempIndex = 0; tempIndex < len; tempIndex++) {
if(tempIndex === 0 && map[tempIndex].start > 0)
tempMap.push({name:'code', start:0, end:map[tempIndex].start});
else if(tempIndex > 0 && map[tempIndex].start > map[tempIndex-1].end)
tempMap.push({name:'code', start:map[tempIndex-1].end, end:map[tempIndex].start});
tempMap.push({name:map[tempIndex].name, start:map[tempIndex].start, end:map[tempIndex].end});
if(tempIndex + 1 === len && map[tempIndex].end < sourceLength)
tempMap.push({name:'code', start:map[tempIndex].end, end:sourceLength});
}
};
return tempMap;
};
function __endCharNoSlash(source, position, find, len) {
var	temp = find.length;
do{position = source.indexOf(find, position + 1)}
while(position !== -1 && !__charNoSlash(source, position));
if(position === -1) position = len - temp;
return position + temp;
};
function __charNoSlash(source, position) {
var	next = 1, len = position - next;
while(len > 0 && source.charAt(len) ==='\\') len = position - (++next);
return ((next - 1) % 2 === 0);
};
return getMap();
};overbyte.include("SourceMap");
overbyte.Crunch = function(str, deep) {
var	i = 0,
notvalid = {singlelinecomment:1,multilinecomment:1},
parsed = [],
re = {
trim:/^\s+|\s+$/g,
space:/\s+/g,
deep:/\s?([\.|\(|\)|;|\:|=|\{|\}|\,|\-|\+|\?|>|<|\*|\/|^|\||\!|&|\[|\]|%]+)\s?/g
},
clean = [
function(str){return str.replace(re.trim,"")},
function(str, line){return clean[0](str.replace(re.space, function(str){return line || str.substr(0, 1)}))},
function(str){return clean[0](clean[1](str," ").replace(re.deep,"$1"))}
];
deep = deep - 1 || 0;
bytedom.forEach(
function(c){
if(!notvalid[c.name]) {
parsed[i] = str.substr(c.start, c.end - c.start);
if(c.name ==="code")
parsed[i] = clean[deep](parsed[i]);
++i;
};
}, overbyte.SourceMap(str, overbyte.JSRules));
return parsed.join("");
};overbyte.CSS = {
collections:[],
create:function(filename, media){
var	css = bytedom.create("style");
css.type ="text/css";
css.media = media ||"all";
css.src = filename;
return overbyte.CSS.pushAndGetId(css);
},
createFromText:function(cssText){
var	css, id;
if(/MSIE/i.test(navigator.userAgent) && !window.opera) {
css = document.createStyleSheet();
css.cssText = cssText;
css = document.getElementsByTagName("style");
overbyte.CSS.collections[id = overbyte.CSS.collections.length] = css.item(css.length - 1);
}
else {
css = bytedom.push(bytedom.create("style"), bytedom.text(cssText));
css.type ="text/css";
id = overbyte.CSS.pushAndGetId(css);
};
return id;
},
getAllCSS:function(){
var	tmp = [], i = 0;
bytedom.forEach(function(css){tmp[i++] = css}, document.getElementsByTagName("style"));
return tmp;
},
getCSSById:function(id){
return overbyte.CSS.collections[id];
},
removeById:function(id){
if(overbyte.CSS.collections[id]) {
bytedom.remove(overbyte.CSS.collections[id]);
overbyte.CSS.collections[id] = null;
}
},
pushAndGetId:function(css){
var	id = overbyte.CSS.collections.length;
bytedom.push(document.getElementsByTagName("head").item(0), css);
overbyte.CSS.collections[id] = css;
return id;
}
};overbyte.include("SourceMap");
overbyte.HighLight = function(theme, fullHighlight) {
this.parse = function(str, moreHtml) {
var i = 0, span ="", highlightSource = [],
parse = {singlelinecomment:comment, multilinecomment:comment, singlequote:quote, doublequote:quote, code:function(){}},
find = [reoperators, renumbers],
repl = [operators, numbers];
parse.code = fullHighlight ? codefull : code;
str = switchLTGT(str);
bytedom.forEach(function(c){
span = str.substr(c.start, c.end - c.start);
highlightSource[i++] = parse[c.name] ? parse[c.name](span, find, repl) : span;
}, overbyte.SourceMap(str, overbyte.JSRules));
str = i ? highlightSource.join("") : parse.code(str, find, repl);
return (!moreHtml ? str : addHtml(str, moreHtml)).replace(/<span class="\w+"><\/span>/g,"");
};
function addHtml(str, tabs){return str.replace(/\r\n|\r|\n/g,"<br />").replace(/\t/g, bytedom.forEach(function(e,i,c){c[i]="&nbsp;"}, new Array(tabs || 8)).join(""))};
function code(span, find, repl){return highlightSintax(span, find, repl)};
function codefull(span, find, repl){
return highlightSintax(span, find, repl).replace(/>?([^\<]+)<?/g, function(s){
return s.replace(reglobals, globals).
replace(reproperties, properties).
replace(remethods, methods)
})};
function comment(span){return"<span class=\"".concat(theme.comments,"\">", span,"</span>")};
function getReplacement(color){return"<span class=\"".concat(color,"\">$1</span>")};
function highlightSintax(str, find, replace){bytedom.forEach(function(e, i){str = str.replace(e, replace[i])}, find); return str};
function normalizeRe(arr, f, re){return bytedom.forEach(function(e,i,m){m[i] = m[i].replace(f, re)},arr.concat())};
function quote(span){return"<span class=\"".concat(theme.strings,"\">", span,"</span>")};
function re(i){return new RegExp(jsSyntax[i],"g")};
function switchLTGT(str){return str.replace(/</g,"&lt;").replace(/>/g,"&gt;")};
function reswitchLTGT(str){return str.replace(/\&lt;/g,"<").replace(/\&gt;/g,">")};
function init(){
var	key, tmp = [];
if(bytedom.some(function(str){return str === undefined}, jsColors))
jsColors = [];
else {
globals = getReplacement(theme.globals);
properties = getReplacement(theme.properties);
methods = getReplacement(theme.methods);
};
reglobals = new RegExp("\\b(".concat(
normalizeRe(overbyte.HighLight.core.Functions,/(\*|\.| )/g,"").join("|"),"|",
normalizeRe(overbyte.HighLight.core.Properties,/(\*|\.| )/g,"").join("|"),"|",
normalizeRe(overbyte.HighLight.core.Statements,/(\*|\.| )/g,"").join("|"),"|",")\\b"),"g");
for(key in overbyte.HighLight.core.Objects) {
if(overbyte.HighLight.core.Objects[key].properties.length)
tmp.push(normalizeRe(overbyte.HighLight.core.Objects[key].properties,/(\*|\.| )/g,"").join("|"));
};
reproperties = new RegExp("\\b(".concat(tmp.join("|"),")\\b"),"g");
tmp = [];
for(key in overbyte.HighLight.core.Objects) {
if(overbyte.HighLight.core.Objects[key].methods.length)
tmp.push(normalizeRe(overbyte.HighLight.core.Objects[key].methods,/(\*|\.| )/g,"").join("|"));
};
remethods = new RegExp("\\b(".concat(tmp.join("|"),")\\b"),"g");
renumbers =/(\b[0-9]+\b|\b[0-9]*\.[0-9]+\b)/g;
reoperators = new RegExp(switchLTGT("(".concat(normalizeRe(overbyte.HighLight.core.Operators,/(\\|\^|\$|\*|\+|\?|\.|\:|\!|\||\,)/g,"\\$1").join("|"),")")),"g");
};
var jsColors = [theme.globals, theme.properties, theme.methods],
operators = getReplacement(theme.operators),
numbers = getReplacement(theme.numbers),
globals ="", properties ="", methods ="",
reglobals, reproperties, remethods, renumbers, reoperators;
init();
};
overbyte.HighLight.core = {"Functions":["Array","alert","Boolean","Date","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","Error","eval","Function","isFinite","isNaN","Number","Object","parseFloat","parseInt","RegExp","String","unescape"],"Objects":{"Array":{"properties":["index","input","length"],"statics":[],"methods":["concat","every","filter","forEach","indexOf","join","lastIndexOf","map","pop","push","reverse","slice","shift","some","sort","splice","unshift"]
},"Boolean":{"properties":[],"statics":[],"methods":[]
},"Date":{"properties":[],"statics":["now","parse","UTC"],"methods":["getDate","getDay","getFullYear","getHours","getMilliseconds","getMinutes","getMonth","getSeconds","getTime","getTimezoneOffset","getUTCDate","getUTCDay","getUTCFullYear","getUTCHours","getUTCMilliseconds","getUTCMinutes","getUTCMonth","getUTCSeconds","getYear *","setDate","setFullYear","setHours","setMilliseconds","setMinutes","setMonth","setSeconds","setTime","setUTCDate","setUTCFullYear","setUTCHours","setUTCMilliseconds","setUTCMinutes","setUTCMonth","setUTCSeconds","setYear *","toGMTString *","toLocaleDateString","toLocaleTimeString","toUTCString"]
},"Error":{"properties":["description","fileName","lineNumber","message","name","number","stack"],"statics":[],"methods":[]
},"Function":{"properties":["arguments *","arity *","caller","length","name"],"statics":[],"methods":["apply","call"]
},"Math":{"properties":["E","LN2","LN10","LOG2E","LOG10E","PI","SQRT1_2","SQRT2"],"statics":[],"methods":["abs","acos","asin","atan","atan2","ceil","cos","exp","floor","log","max","min","pow","random","round","sin","sqrt","tan"]
},"Number":{"properties":["MAX_VALUE","MIN_VALUE","NaN","NEGATIVE_INFINITY","POSITIVE_INFINITY"],"statics":[],"methods":["toExponential","toFixed","toPrecision"]
},"Object":{"properties":["constructor","prototype"],"statics":[],"methods":["__defineGetter__","__defineSetter__","eval","hasOwnProperty","isPrototypeOf","__lookupGetter__","__lookupSetter__","propertyIsEnumerable","toSource","toString","unwatch","valueOf","watch"]
},"Packages":{"properties":["className","java","JavaPackage","JavaObject","JavaArray","netscape","sun"],"statics":[],"methods":["JavaClass"]
},"RegExp":{"properties":["global","ignoreCase","lastIndex","multiline","source"],"statics":[],"methods":["exec","test"]
},"String":{"properties":["length"],"statics":["fromCharCode"],"methods":["charAt","charCodeAt","concat","indexOf","lastIndexOf","match","replace","search","slice","split","substr","substring","toLowerCase","toUpperCase"]
}
},"Operators":["+","-","*","/","%","++","--","-","=","+=","-=","*=","/=",">>=","<<=",">>>=","&=","|=","^=","|","^","~","<<",">>",">>>","==","!=","===","!==",">",">=","<","<=","&&","||","!","?",",",".",":","&",";"],"Properties":["Infinity","NaN","undefined","null","false","true"],"Statements":["block","break","case","const","continue","do","export","for","each","if","else","import","label","return","switch","throw","try","catch","var","while","with","delete","function","in","instanceof","new","this","typeof","void"]
};overbyte.include("CSS","Crunch","HighLight");
overbyte.Editor = function(parent, phpfolder, jsfolder, rows){
this.addHeaderCode = function(code){
arbitrarysource += code;
};
this.allowjhp = function(){
jhpsource = arguments[0];
};
this.clearHeaderCode = function(){
arbitrarysource ="";
};
this.destruct = function(){
removeSuggest();
overbyte.CSS.removeById(cssid);
with(separator)
onmousemove = onmouseup = onmousedown = function(){};
fx.clear(separator);
while(parent.hasChildNodes()) {
fx.clear(parent.firstChild);
dom.remove(parent.firstChild);
};
this.destruct = function(){};
};
this.setAreaValue = function(code){
area.value = code;
};
this.draw = function(){
var	self = Editor = this;
clear(parent);
setCSS();
dom.push(parent, menu, createEditArea(), separator, dom.push(panel, debug, output));
setAreaSize();
setEvents(self);
createMenu(self);
this.draw = function(){};
};
function downloadCode(download, withcrunch){
var	name, xhr, content ="";
try {
if(area.value && (xhr = json.xhr()) && ((ie && window.confirm("Are You sure to download ?"))|| (name = window.prompt("Please choose a name", lastchoosedname ||"")))) {
lastchoosedname = name ||"noname.js";
if(download.indexOf("?") > -1 && !/^php/i.test(lastchoosedname.split(".").pop()))
lastchoosedname +=".php";
content ="".concat("name=", encodeURIComponent(lastchoosedname),"&content=", encodeURIComponent(withcrunch ? overbyte.Crunch(area.value, withcrunch) : area.value));
xhr.open("post", phpfolder.concat("download.php"), false);
xhr.setRequestHeader('Content-Length', content.length);
xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
xhr.send(content);
content = xhr.responseText;
if(/^[a-f0-9]{40}$/.test(content))
document.location.href = phpfolder.concat(download.concat(download.indexOf("?") > -1 ?"&":"?","key=", content));
else
alert("There are some problems to download this content, please try again");
};
}catch(e){debug.innerHTML = e.message.concat("<hr />", debug.innerHTML)};
};
function removeDefaults(){
dom.forEach(function(e){with(e.style)padding = margin = border ="0"}, arguments);
};
function createMenu(self){
function highLight(HighLight){
debug.onclick("<script></script><link rel=\"stylesheet\" type=\"text/css\" media=\"all\" href=\"".concat(jsfolder,"overbyte/HighLight/HighLight.css\" />\n<pre>", HighLight.parse(area.value),"</pre>"));
};
function forceClearAll(self, rows){
self.destruct();
self = new overbyte.Editor(parent, phpfolder, jsfolder, rows);
self.addHeaderCode(arbitrarysource);
self.draw();
};
function clearAll(){
var	clear = (area.value && window.confirm("Are You sure to clear all ?\n(area wrote code will be deleted)")) || !area.value;
if(clear)
forceClearAll(self, rows);
return clear;
};
function downloadcrunchCode(withcrunch){
downloadCode("getdownload.php?pack=true", withcrunch);
};
function addEvents(menu, item, list){
dom.toggle(item);
menu.onmouseover = function(){
var	position = fx.$position(menu);
menu.className ="over";
if(!item.hasChildNodes()) {
position.y += menuheight;
fx.position(item, position);
dom.forEach(function(e){
e.item = spanContent(e.label);
e.item.onmouseover = function(){this.className ="oversub"};
e.item.onmouseout = function(){this.className =""};
if(e.action) {
e.item.onclick = function(){e.action(e.item)};
if(e.item.style.cursor)
e.item.style.cursor ="pointer";
};
if(e.exec)
e.exec(e.item);
dom.push(item, e.item);
}, list);
item.onmouseover = function(){clearTimeout(menu.timeout)};
item.onmouseout = function(){menu.onmouseout()};
fx.alpha(item, 0);
menu.onmouseover();
}
else {
clearTimeout(menu.timeout);
fx.fade(item, Math.round(item.style.opacity * 100), 100, 10);
if(item.style.display ==="none")
dom.toggle(item);
};
};
menu.onmouseout = function(){
this.timeout = setTimeout(function(){
fx.fade(item, Math.round(item.style.opacity * 100), 0, 5, function(){
menu.className ="";
dom.toggle(item);
});
}, 250);
};
};
function spanContent(content){
return dom.push(dom.create("span"), dom.text(content));
};
var	file = spanContent("File"),
settings = spanContent("Settings"),
help = spanContent("About"),
extra = spanContent("Extra"),
dload = spanContent("Download"),
filediv = dom.create("div"),
settingsdiv = dom.create("div"),
helpdiv = dom.create("div"),
extradiv = dom.create("div"),
dloaddiv = dom.create("div"),
crunchstrings = ["Crunch - disabled","Crunch - comments","Crunch - spaces","Crunch - full"];
addEvents(dload, dloaddiv, [
{label:"just area code", action:function(item){
downloadcrunchCode(0);
}},
{label:crunchstrings[1], action:function(item){
downloadcrunchCode(1);
}},
{label:crunchstrings[2], action:function(item){
downloadcrunchCode(2);
}},
{label:crunchstrings[3], action:function(item){
downloadcrunchCode(3);
}}
]);
addEvents(extra, extradiv, [
{label:crunchstrings[usecrunch], action:function(item){
dom.replace(item.firstChild, dom.text(crunchstrings[++usecrunch]));
if(usecrunch + 1 === crunchstrings.length)
usecrunch = -1;
}},
{label:"Crunch - view", action:function(item){
var	content = (output.contentDocument || output.contentWindow.document),
level = usecrunch === -1 ? 3 : usecrunch;
if(level > 0) {
content.open();
try{content.write("<pre>".concat(overbyte.Crunch(area.value, level).replace(/</g,"&lt;"),"</pre>"))}
catch(e){debug.innerHTML = e.message.concat("<hr />", debug.innerHTML)};
content.close();
}
else
alert("Crunch is not enabled, please choose a mode");
}},
{label:"header - add code", action:function(item){
if(area.value) {
Editor.addHeaderCode(area.value);
if(window.confirm("clean the area ?")) {
area.value ="";
element.scrollTop = 0;
}
};
}},
{label:"header - clear code", action:function(item){
if(window.confirm("put headers code in area ?"))
area.value += arbitrarysource;
Editor.clearHeaderCode();
}},
{label:"highglight - fast", action:function(item){
highLight(HighLightFast);
}},
{label:"highglight - full", action:function(item){
highLight(HighLightFull);
}}
]);
addEvents(settings, settingsdiv, [
{label:"Disable auto-indent", action:function(item){
dom.replace(item.firstChild, dom.text(useautoindent ?"Enable auto-indent":"Disable auto-indent"));
useautoindent = !useautoindent;
}},{label:"Enable jhp", action:function(item){
if(jhpsource) {
self.allowjhp(null);
dom.replace(item.firstChild, dom.text("Enable jhp"));
}
else {
self.allowjhp(jhp);
dom.replace(item.firstChild, dom.text("Disable jhp"));
debug.onclick("jhpinfo();");
};
}},
{label:"Use JS 1.7", action:function(item){
dom.replace(item.firstChild, dom.text(newjs ?"Use JS 1.7":"Disable JS 1.7"));
newjs = !newjs;
if(newjs) {
debug.onclick("let(enabled=true)parent.overbyte.Editor.work.newjs=enabled;");
if(overbyte.Editor.work.newjs !== true) {
arguments.callee(item);
if(window.confirm("Your browser doesn't support JavaScript 1.7\nDo You want a better browser ?"))
document.location.href ="http://www.mozilla.com/en-US/";
};
};
}},
{label:"Clear debug", action:function(){
debug.innerHTML ="";
}},
{label:"Popup mode", action:function(){
window.open(document.location.href,"","width=800,height=600");
}},
{label:"Clear - SAFE", action:clearAll},
{label:"Clear - 99 rows", action:function(){
forceClearAll(self, 99);
}},
{label:"Clear - 999 rows", action:function(){
forceClearAll(self, 999);
}}
,
{label:"Clear - max rows", action:function(){
forceClearAll(self, 4999);
}}
]);
addEvents(help, helpdiv, [
{label:"What is this ?",
exec:function(){
output.src = jsfolder.concat("overbyte/Editor/what.html");
},
action:function(){
this.exec();
}},
{label:"What is jhp ?", action:function(){
output.src = jsfolder.concat("overbyte/Editor/jhp.html");
}},
{label:"Credits", action:function(){
output.src = jsfolder.concat("overbyte/Editor/credits.html");
}},
{label:"Author", action:function(){
output.src = jsfolder.concat("overbyte/Editor/author.html");
}}
]);
addEvents(file, filediv, [
{label:"Open",
exec:function(item){
var	self = this;
if(!this.frame || !this.form || !this.input) {
var	frame ='<iframe src="'.concat(phpfolder,'upload.php" id="overbyteeditoruploadframe" name="overbyteeditoruploadframe"></iframe>'),
form ='<form method="post" action="'.concat(phpfolder,'upload.php" target="overbyteeditoruploadframe" enctype="multipart/form-data" id="overbyteeditoruploadform"><input type="file" name="filedata" /></form>'),
input = null,
i = 0;
filediv.innerHTML += frame.concat(form);
this.frameloaded = function(self){
this.loaded = function(i, f){
function showUpload(){
var	trows = 0,
content = (self.frame.contentDocument || self.frame.contentWindow.document).getElementsByTagName("pre"),
result = content.length ? content.item(0).textContent || content.item(0).innerText : false;
if(result && result.constructor === String) {
trows = Math.ceil(result.replace(/\n|\r|\r\n/g,"\n").split("\n").length);
if(trows >= (rows || 99) && window.confirm("Too many lines.\nDo You want to reset the Editor ?")) {
forceClearAll(Editor, trows + 99);
parent.getElementsByTagName("textarea").item(0).value = result;
}
else
area.value = result;
}
else
area.value ="Upload problems, please try again.";
};
clearInterval(i);
f.loaded = function(){};
area.value ="\n[ upload completed in ".concat((((new Date()).getTime() - self.time) / 1000).toFixed(3)," seconds ]");
setTimeout(showUpload, 500);
};
};
this.frame = dom.get("overbyteeditoruploadframe");
this.form = dom.get("overbyteeditoruploadform");
this.input = this.form.getElementsByTagName("input").item(0);
this.input.onchange = function(){
setTimeout(function(){
var	clear = (area.value && window.confirm("Are You sure to clear all ?\n(area wrote code will be deleted)")) || !area.value,
frameloaded = new self.frameloaded(self);
if(self.input.value && clear) {
self.time = (new Date()).getTime();
self.frame.onreadystatechange = function(){
if(/loaded|complete/i.test(self.frame.readyState))
frameloaded.loaded(i, frameloaded);
};
self.frame.onload = function(){frameloaded.loaded(i, frameloaded)};
area.value ="\n[ upload progress, please wait ]";
i = setInterval(function(){area.value =".".concat(area.value)}, 100);
self.form.submit();
self.input.value ="";
}
else if(!self.input.value)
alert("Your browser (Opera ?) didn't select file correctly, please try again.\nTrick: try to use a double click on file or to select with a right click");
}, 250);
};
with(this.form.style)
padding = margin = border ="0";
with(this.frame.style) {
position ="absolute";
top ="-10000px";
left ="-10000px";
};
with(this.input.style) {
position ="absolute";
top ="-10000px";
left ="-10000px";
padding = margin = border ="0";
width ="220px";
height ="20px";
if(cursor)
cursor ="pointer";
};
fx.alpha(this.input, 0);
item.onmouseover = function(){
var	style = this.style,
divwidth = fx.$size(filediv).width;
with(self.input.style) {
top = style.top;
left ="".concat(fx.$position(filediv).x - divwidth - 30,"px");
};
};
this.input.onmouseout = function(){
with(this.style) {
top ="-10000px";
left ="-10000px";
};
};
};
}},
{label:"Save As", exec:function(item){savebutton = item}, action:function(){
downloadCode("getdownload.php", false);
}}
]);
dom.push(menu, file, settings, extra, dload, help, dom.create("br"), filediv, settingsdiv, extradiv, dloaddiv, helpdiv);
filediv.style.zIndex = settingsdiv.style.zIndex = helpdiv.style.zIndex = extradiv.style.zIndex = dloaddiv.style.zIndex = 1;
if(!overbyte.Editor.neverShowed) {
help.onmouseover();
help.onmouseout();
overbyte.Editor.neverShowed = true;
}
};
function addTDEvents(td){
td.clicked = 0;
td.onmousedown = function(){
if((td.className ="left".concat([" verify"," error",""][td.clicked++])) ==="left")
td.clicked = 0;
return false;
};
};
function clear(){
dom.forEach(function(e){dom.forEach(function(e){dom.remove(e)}, e.childNodes)}, arguments);
};
function createEditArea(){
var	size = fx.$size(parent),
tbody = dom.create("tbody"),
i = 0, j = rows || 999,
tr, td;
table.setAttribute("border", 0);
table.setAttribute("cellPadding", 0);
table.setAttribute("cellSpacing", 0);
while(i++ < j) {
tr = dom.create("tr");
td = dom.create("td");
td.className ="left";
addTDEvents(td);
dom.push(tbody, dom.push(tr, dom.push(td, dom.text(i))));
if(i === 1) {
tr.setAttribute("valign","top");
td = dom.create("td");
td.className ="right";
td.setAttribute("rowSpan", j);
dom.push(tr, dom.push(td, area));
};
};
return dom.push(element, dom.push(table, tbody));
};
function removeSuggest(){
if(parent.lastdiv) {
clear(parent.lastdiv);
dom.remove(parent.lastdiv);
parent.lastdiv = null;
};
};
function setAreaEvents(){
function getNewLine(str){
return str.indexOf("\r\n") > -1 ?"\r\n": str.indexOf("\n") > -1 ?"\n":"\r";
};
function addTabs(str, tab){
var	newline = getNewLine(str),
lines = str.split(newline);
dom.forEach(function(l, i){lines[i] = tab.concat(lines[i])}, lines);
return lines.join(newline);
};
function getFontSize(element){
var	fsize = dom.getStyle(element,"font-size");
return parseFloat(fsize.substr(0, fsize.length - 2));
};
function getTextAreaCursorPosition(area){
var	pos = {x:0,y:0}, tmp = [], pre;
if(area.setSelectionRange) {
pre = dom.create("pre");
removeDefaults(pre);
pre.style.cssText ="line-height:".concat(dom.getStyle(area,"line-height"),";font-size:", dom.getStyle(element,"font-size"),";font-family:", dom.getStyle(element,"font-family")
);
for(tmp in area.style){try{pre.style[tmp] = area.style[tmp]}catch(e){}};
dom.push(
area.parentNode,
dom.push(pre,
dom.push(dom.create("span"), dom.text(area.value.substr(0, area.selectionEnd))),
dom.push(dom.create("span"), dom.text(" "))
)
);
tmp = [fx.$position(pre.getElementsByTagName("span").item(1)), fx.$position(pre), fx.$position(area)];
pos.x = tmp[2].x + (tmp[0].x - tmp[1].x);
pos.y = tmp[2].y + (tmp[0].y - tmp[1].y);
dom.remove(pre);
}
else {
pre = document.selection.createRange();
pos.x = pre.boundingLeft;
pos.y = pre.boundingTop;
};
return pos;
};
function createSuggest(div, area){
function listGenerator(list){
var	span = dom.push(dom.create("span"), dom.text(list.label));
dom.push(div, span);
dom.forEach(linkManager, list.data);
};
function linkManager(e){
var	link = dom.push(dom.create("a"), dom.text(e));
link.href ="#";
link.onkeydown = keydown;
link.onmouseover = function(){this.focused = true; this.focus(); this.className ="over"};
link.onmouseout = function(){this.focused = false; this.className =""};
link.onclick = function(){
var	value = this.firstChild.nodeValue;
this.onmouseout();
area.value = area.value.substr(0, range.start).concat(value, area.value.substring(range.end));
removeSuggest();
area.focus();
return false;
};
dom.push(div, link);
};
function keydown(evt){
var	tmp;
evt = normalizeEvent(evt);
switch(evt.keyCode) {
case	13:this.onclick();
break;
case	27:removeSuggest();
area.focus();
break;
case	38:dom.forEach(function(a,i,list){
if(i > 0 && a.focused) {
a.onmouseout(tmp = list[i - 1]);
if(i === 1)
div.scrollTop = 0;
}
}, div.getElementsByTagName("a"));
if(tmp)
tmp.onmouseover();
break;
case	40:dom.forEach(function(a,i,list){
if(i < list.length - 1 && a.focused)
a.onmouseout(tmp = list[i + 1]);
},div.getElementsByTagName("a"));
if(tmp)
tmp.onmouseover();
break;
};
return false;
};
var	range = getSelectionRange(area);
range.lastChar = range.end > 0 ? area.value.substr(range.end - 1, 1) :" ";
range.Functions = {label:"Functions",data:overbyte.HighLight.core.Functions};
range.Properties = {label:"Properties",data:overbyte.HighLight.core.Properties};
range.Statements = {label:"Statements",data:overbyte.HighLight.core.Statements};
range.Objects = {label:"Statements",data:overbyte.HighLight.core.Objects};
if(range.lastChar !==".") {
range.Functions.data.sort();
range.Properties.data.sort();
range.Statements.data.sort();
listGenerator(range.Functions);
listGenerator(range.Properties);
listGenerator(range.Statements);
}
else {
range.lastChar = area.value.substr(0, range.start).replace(/^([^\x00]*)\b(\w+)\.$/,"$2");
for(range.key in range.Objects.data) {
if(range.key === range.lastChar) {
if(range.Objects.data[range.key].properties.length)
listGenerator({label:"Properties",data:range.Objects.data[range.key].properties});
if(range.Objects.data[range.key].statics.length)
listGenerator({label:"Static Methods",data:range.Objects.data[range.key].statics});
if(range.Objects.data[range.key].methods.length)
listGenerator({label:"Methods",data:range.Objects.data[range.key].methods});
range.key = true;
break;
}
};
listGenerator({label:"Generic Object - Properties",data:range.Objects.data.Object.properties});
listGenerator({label:"Generic Object - Methods",data:range.Objects.data.Object.methods});
};
area.blur();
div.getElementsByTagName("a").item(0).onmouseover();
};
function getSelectionRange(area){
var	range = {};
if(area.setSelectionRange) {
range.start = area.selectionStart;
range.end = area.selectionEnd;
}
else {
range.range = document.selection.createRange();
range.duplicate = range.range.duplicate();
range.duplicate.moveToElementText(area);
range.duplicate.setEndPoint("EndToEnd", range.range);
range.start = range.duplicate.text.length - range.range.text.length;
range.end = range.start + range.range.text.length;
range = {start:range.start, end:range.end};
};
return range;
};
function setSelectionRange(area, position, start){
var	tmp = {position:position};
if(area.setSelectionRange)
area.selectionStart = area.selectionEnd = tmp.position - 1;
else {
tmp.range = area.createTextRange();
tmp.range.collapse(true);
tmp.range.moveStart("character", tmp.position - start.split(getNewLine(start)).length);
tmp.range.select();
};
};
function normalizeEvent(evt){
if(!evt)
evt = window.event;
if(!evt.keyCode)
evt.keyCode = evt.wich;
evt.prevent = function(){
if(evt.stopPropagation)
evt.stopPropagation();
dom.preventDefault(evt);
};
return evt;
};
area.onfocus = function(){
removeSuggest();
this.onkeydown = function(evt){
var	result = false;
evt = normalizeEvent(evt);
if(evt.ctrlKey || evt.keyCode === 17) {
if(!this.ctrl)
evt.prevent(this.ctrl = !result);
else {
switch(evt.keyCode) {
case	13:debug.onclick();
evt.prevent();
break;
case	16:case	32:evt.pos = getTextAreaCursorPosition(this);
evt.area = this;
evt.table = ie ? 0 : this.parentNode.parentNode.parentNode.parentNode.parentNode.scrollTop * .986;
parent.lastdiv = dom.create("div");
parent.lastdiv.id = parent.id.concat("-suggest");
with(parent.lastdiv.style){
top ="".concat((evt.pos.y + getFontSize(evt.area)) - evt.table,"px");
left ="".concat(evt.pos.x,"px");
};
dom.push(document.body, parent.lastdiv);
dom.addEvent(parent,"mouseup", function(){
removeSuggest();
dom.removeEvent(parent,"mouseup", arguments.callee);
});
createSuggest(parent.lastdiv, this);
evt.prevent();
break;
case	79:setTimeout(function(){alert("Please use File menu to Open a file")}, 100);
evt.prevent();
break;
case	83:setTimeout(function(){
if(savebutton)
savebutton.onclick();
else {
menu.getElementsByTagName("span").item(0).onmouseover();
menu.getElementsByTagName("span").item(0).onmouseout();
savebutton.onclick();
}
}, 100);
evt.prevent();
break;
default:
result = true;
break;
}
}
}
else if(evt.keyCode == 9) {evt.tab = String.fromCharCode(evt.keyCode);
with(getSelectionRange(this)) {
evt.start = start;
evt.end = end;
};
evt.diff = evt.end - evt.start;
evt.str = evt.diff ? addTabs(this.value.substr(evt.start, evt.end - evt.start), evt.tab) : evt.tab;
if(this.setSelectionRange) {
this.value = this.value.substr(0, evt.start++).concat(evt.str, this.value.substring(evt.end));
this.setSelectionRange(evt.start, evt.end + (evt.str.length - evt.diff));
}
else
document.selection.createRange().text = evt.str;
evt.prevent();
}
else if(useautoindent && evt.keyCode == 13 && area.value) {evt.range = getSelectionRange(area);
evt.re =/^([\t]+)([^\x00]*)$/;
evt.start = area.value.substr(0, evt.range.start);
evt.end = area.value.substring(evt.range.end);
evt.lastLine = evt.start.split(getNewLine(evt.start)).pop();
if(evt.re.test(evt.lastLine)) {
evt.lastLine = evt.lastLine.replace(evt.re,"$1");
area.value = evt.start.concat(String.fromCharCode(evt.keyCode), evt.lastLine, evt.end);
setSelectionRange(this, evt.range.end + evt.lastLine.length + 2, evt.start);
evt.prevent();
}
else
result = true;
}
else
result = true;
return result;
};
this.onkeyup = function(evt){this.ctrl = false};
};
area.onblur = function(){
this.ctrl = false;
this.onkeydown = this.onkeyup = function(){};
};
};
function setAreaSize(){
var	style = area.style;
style.width ="".concat(fx.$size(element).width - 66,"px");
style.height ="".concat(fx.$size(table).height,"px");
separator.style.width ="".concat(fx.$size(parent).width,"px");
};
function setCSS(){
var	id = parent.id,
csscontent = overbyte.getContent(jsfolder.concat("overbyte/Editor/Editor.css"));
if(!id) {
do {id ="panel-".concat(Math.ceil(Math.random() * 123456789))}
while(document.getElementById(id));
parent.id = id;
};
cssid = overbyte.CSS.createFromText(csscontent.replace(/\{webreflection\}/g, parent.id));
removeDefaults(menu, element, table, area, separator, panel);
menu.className ="menu";
element.className ="editor";
separator.className ="separator";
debug.className ="debug";
output.className ="output";
panel.className ="panel";
with(parent.style) {
overflow ="hidden";
padding ="0";
};
with(element.style) {
width ="100%";
height ="60%";
overflow ="auto";
};
with(debug.style){
overflow ="auto";
position ="relative";
top ="8px";
left ="4px";
width ="300px";
};
with(output.style){
scrolling ="auto";
position ="relative";
top ="8px";
left ="8px";
};
output.setAttribute("frameBorder", 0);
area.style.overflow ="hidden";
panel.style.height ="40%";
separator.style.position ="absolute";
};
function setEvents(self){
function onDragInit(){
dom.toggle(debug);
dom.toggle(output);
};
function onDragEnd(){
dom.toggle(debug);
dom.toggle(output);
onDragProgress();
if((top = top - 14 - menuheight) >= 0)
debug.style.height = output.style.height ="".concat(top,"px");
if((top = size.width - 316) >= 0)
output.style.width ="".concat(top,"px");
};
function onDragProgress(){
top = fx.$position(separator).y - position.y - menuheight;
size = fx.$size(parent);
element.style.height ="".concat(top,"px");
if((top = size.height - top) >= 0)
panel.style.height ="".concat(top,"px");
};
function onResize(){
var	overflow = element.style.overflow;
element.style.overflow ="hidden";
setAreaSize();
onDragInit();
onDragEnd();
element.style.overflow = overflow;
};
function onUnload(){
dom.removeEvent(window,"resize", onResize);
self.destruct();
};
var	top = 0, size = {}, position = fx.$position(parent);
menuheight = fx.$size(menu).height;
fx.drag(separator, onDragInit, onDragEnd, onDragProgress, {$y:position.y + menuheight, y$:position.y + fx.$size(parent).height - fx.$size(separator).height, $x:position.x, x$:position.x});
dom.addEvent(window,"resize", onResize);
dom.addEvent(window,"unload", onUnload);
debug.onclick = function(code){
var	execute = typeof(code) ==="string"? code : area.value,
notags = !/^<script[^\>]*>[^\x00]*<\/script>/.test(execute),
content = (output.contentDocument || output.contentWindow.document),
type = newjs ?"application/javascript;version=1.7":"text/javascript";
page ="<script type=\"".concat(type,"\">", arbitrarysource),
headers ="<script type=\"".concat(type,"\">\n", jhpsource,"\n</script>\n", page);
overbyte.Editor.work = {execute:execute, prompt:debug, handler:function(e){
debug.innerHTML = e.message.concat("<hr />", debug.innerHTML);
}};
try {
if(usecrunch && notags)
overbyte.Editor.work.execute = overbyte.Crunch(overbyte.Editor.work.execute, usecrunch);
if(notags)
page = jhpsource ? headers.concat("try{jhp.exec(new Function('',parent.overbyte.Editor.work.execute))}catch(e){parent.overbyte.Editor.work.handler(e)}</script>") : page.concat("try{eval(parent.overbyte.Editor.work.execute)}catch(e){parent.overbyte.Editor.work.handler(e)}</script>\n");
else
page = jhpsource ? headers.concat("</script>\n", overbyte.Editor.work.execute) : page.concat("</script>\n", overbyte.Editor.work.execute);
content.open();
content.write(page);
content.close();
}catch(e){overbyte.Editor.work.handler(e)};
};
onResize();
setAreaEvents();
};
var	dom = bytedom,
fx = bytefx,
json = byteson,
ie =/MSIE/i.test(navigator.userAgent) && !window.opera,
theme = {"comments":"jshcomments","strings":"jshstrings","numbers":"jshnumbers","operators":"jshoperators","globals":"jshglobals","properties":"jshproperties","methods":"jshmethods"},
HighLightFull = new overbyte.HighLight(theme, true),
HighLightFast = new overbyte.HighLight(theme, false),
Editor;
var	menu = dom.create("div"),
element = dom.create("div"),
separator = dom.create("div"),
panel = dom.create("div"),
debug = dom.create("div"),
output = dom.create("iframe"),
area = dom.create("textarea"),
table = dom.create("table");
var	cssid = null,
jhpsource = null,
arbitrarysource ="",
lastchoosedname = null,
savebutton = null,
newjs = false,
usecrunch = 0,
useautoindent = true,
menuheight = 0;
};jhp = overbyte.getContent("bootstrap.php?jhp|jhp.array|jhp.filesystem|jhp.handling|jhp.string|js");
bytedom.addEvent(window,"DOMContentLoaded", function(){
(new overbyte.Editor(bytedom.get("workarea"),"php/","javascript/", 99)).draw()
});